package leetcode;

import java.util.Deque;
import java.util.LinkedList;

public class Code12 {

    public static void main(String[] args) {
        Code12 code12 = new Code12();
        code12.push(1);
        System.out.println(code12.pop());
        code12.push(2);
        code12.push(3);
        System.out.println(code12.min());
        code12.push(1);
        System.out.println(code12.min());
    }
    public static Deque<Integer> mq=new LinkedList<>();
    public static Deque<Integer> min=new LinkedList<>();

    public Code12() {
        // do intialization if necessary
    }

    /*
     * @param number: An integer
     * @return: nothing
     */
    public void push(int number) {
        // write your code here
        if (min.size()==0||number<min.getLast()){
            min.addLast(number);
        }else{
            min.addLast(min.getLast());
        }
        mq.addLast(number);
    }

    /*
     * @return: An integer
     */
    public int pop() {
        // write your code here
        min.removeLast();
        return mq.removeLast();
    }

    /*
     * @return: An integer
     */
    public int min() {
        // write your code here
        return min.getLast();
    }

}
